package com.link.base.base.workbreakdown.service;

import com.link.base.base.system.model.Period;
import com.link.base.base.workbreakdown.dao.mybatis.mapper.WorkBreakdownMapper;
import com.link.base.base.workbreakdown.model.WorkBreakdown;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.ServiceException;
import com.link.core.basic.service.BasicServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author liushoulong
 * @date 2018-11-06
 * @desc 任务分解Service
 */
@Service
public class WorkBreakdownServiceImpl extends BasicServiceImpl<WorkBreakdown> implements WorkBreakdownService {

    @Resource
    private WorkBreakdownMapper workBreakdownMapper;

    @Override
    public BasicMapper<WorkBreakdown> getBasicMapper() {
        return workBreakdownMapper;
    }

    /**
     * 查询对应的月度任务量
     **/
    @Override
    public Double queryByExampleMoth(Period p) throws Exception {
        return workBreakdownMapper.queryByExampleMoth(p);
    }

    /**
     * 根据年度计划id批量删除分解任务
     * @param workBreakdown
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor = ServiceException.class)
    public void deleteByAnnualPlanId(WorkBreakdown workBreakdown) throws Exception {
        workBreakdownMapper.deleteByAnnualPlanId(workBreakdown);
    }
}
